package com.zyf.cloud.services.userservice.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.zyf.cloud.services.userservice.entity.UserEntity;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;

/**
 * 用户基本信息表
 *
 * @author zpf
 * @email zyf0744@163.com
 * @date 2019-12-18 17:42:57
 */
public interface UserService extends IService<UserEntity> {

    //判断用户是否存在
    boolean isUserExist(String id);

    //根据提供的id拿密码
    String getPasswordByUserId(String id);

    //用户注册
    Boolean regist2(UserEntity user);
    void insertUser(UserEntity user) throws Exception;
    /**
     * 邮箱激活
     * @param mail 邮箱地址
     * @param code 为存入到Redis的激活码所对应的key。格式是：activation: + 验证码
     * @return true/false，true表示验证成功
     */
    public boolean activate(String mail,String code) throws Exception ;


    //修改密码
//    int upUserPassword(Integer id, String newpassword);

    //修改某一用户的密码
//    int upUserPassword(Integer id, String password, String newpassword);

    @CachePut(cacheNames = "user-list", key = "#id")
// @Cacheable(cacheNames = "user-list", key = "#id")
    UserEntity upUserPasswordRedis(Integer id, String password, String newpassword);

    //查询是否存在
    int findUserByLgName(String name);


    //查询缓存数据 ；Cacheable：从redis中拿数据
    @Cacheable(key = "#id")
    UserEntity findUserById(Integer id);

    //用户登录
    UserEntity login(String name, String password);


    // 通过id查询客户
    UserEntity selectById(Integer id);

    //根据用户名查找用户
    UserEntity findByUsername(String username);

    //根据id修改
    int update(UserEntity user);

    //根据id物理删除
    void deleteById(Integer id);

    Boolean deleteById(UserEntity userEntity);

    Boolean deleteAll();

    UserEntity findByToken(String token);


    void testTrans();
}


